// import { Canceler } from 'axios';
import { pget, ppostJson } from '@/utils/req'
import { modalApi } from '@/utils/modalReq'
// 用户 - 查询用户列表（不分页）
export function getUseList(query: any) {
	return pget(`${modalApi.system}/user/list`, query)
}
export function getAllUserList(query: any) {
	return pget(`${modalApi.system}/common/current-and-parent-org-user/list`, query)
}

// 用户 - 查询用户列表（分页）
export function getUsePageList(query: any) {
	return pget(`${modalApi.system}/user/page`, query)
}

// 新增用户
export function addUser(data: any) {
	return ppostJson(`${modalApi.system}/user/create`, data, {
		headers: {
			currentMerchantId: data?.merchantId,
			Accept: 'application/json',
			'Content-Type': 'application/json',
		},
	})
}

// 修改用户
export function editUser(userId: string, data: any) {
	return ppostJson(`${modalApi.system}/user/update/${userId}`, data, {
		headers: {
			currentMerchantId: data?.merchantId,
			Accept: 'application/json',
			'Content-Type': 'application/json',
		},
	})
}

// 删除用户
export function deleteUser(query: any) {
	return ppostJson(
		`${modalApi.system}/user/delete/${query.userId}`,
		{},
		{
			headers: {
				currentMerchantId: query.merchantId,
				Accept: 'application/json',
				'Content-Type': 'application/json',
			},
		},
	)
}

// 查看用户
export function viewUser(userId: string, query: any) {
	return pget(`${modalApi.system}/user/info/${userId}`, query, {
		headers: {
			currentMerchantId: query?.merchantId,
		},
	})
}

// 用户分配角色
export function userShareRole(userId: any, currentMerchantId: any, data: any) {
	return ppostJson(`${modalApi.system}/user/${userId}/assign/roles`, data, {
		headers: {
			currentMerchantId,
			Accept: 'application/json',
			'Content-Type': 'application/json',
		},
	})
}

// 获取用户信息
export function userInfo() {
	return pget(`${modalApi.system}/login-user/info`)
}
